// pages/manage/spare/spare.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
      cycleAllData:[],
      orderdataSource:[],
      array3: [],
      value3:0,
      testArr:[{
        waybillno:"123456",
        statusDes:"???",
        dateAndTimeRequired:"2022-03-25 16:30:00"
      },
      {
        waybillno:"123456",
        statusDes:"???",
        dateAndTimeRequired:"2022-03-25 16:30:00"
      }]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let self = this
    this.getequiment()
    
  },
  getData(){
    let self = this
    this.axios.query(
      "PartsPeriod",
      {},
      { serialOrLotNumber: self.data.array3[self.data.value3], searchType: "chart" },
      ""
    )
    .then(function (response) {
      let cycleData=[]
      console.log(response.data)
      if (response.data.rows[0].beamOnHour != undefined) {
        let arr=[]
        response.data.rows[0].beamOnHour.x.forEach(e => {
          let obj={
            x:e,
            y:"",
            y2:""
          }
          arr.push(obj)
          cycleData = arr
        });
        response.data.rows[0].beamOnHour.y.forEach((e,index) => {
          cycleData[index].y =e
        });
      }
      if (response.data.rows[0].partsPeriod != undefined) {
        response.data.rows[0].partsPeriod.y.forEach((e,index) => {
          cycleData[index].y2 = e
        });
      }
      self.setData({
        cycleAllData:cycleData,
        orderdataSource:response.data.rows[0].logistics
      })
    });
  },
  bindPicker3Change: function(e) {
    this.setData({
        value3: e.detail.value
    })
    this.getData()
  },
  getequiment(){
    this
    .axios
    .custom("AllInstalledProducts", "serialOrLotNumbers", {
      id: this.Store.getItem("userid"),
    })
    .then((result) => {
      console.log(result);
      this.setData({
        array3:result.data
      })
      if(result.data.length>0){
        this.getData()
      }
      
    })
    .catch((err) => {
      self.$notify(err.data.msg, "error");
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})